/*	kd:
	
	Storage for the spell tome icons. They're in the order of the spells list
	loaded into it. This is here so that we can change things like the Sigil or
	Firebreath icons when the time comes.
	
	*/

class Gc_SpellIcons {
	private Array <class <SharedTome> >		tome_class;
	private Array <TextureId>				sprite_backup;
	private Array <TextureId>				sprite;
	private TextureId						empty_sprite;
	private Gc_SpellCollection				spell_list;
	
	void Reset () {
		empty_sprite = Gc_Sprite.Load("b02kz0");
		tome_class		.clear();
		sprite_backup	.clear();
		sprite			.clear();
	}
	
	void FromSpellCollection (Gc_SpellCollection list) {
		int size = list.TomeCount();
		
		Reset();
		
		for(int i = 0; i < size; i++) {
			let tome = list.TomeAt(i);
			
			sprite.push(0);
			sprite [i] = GetDefaultByType(tome).icon;
			tome_class.push(tome);
		}
		
		sprite_backup.copy(sprite);
		spell_list = list;
		// tome_class.copy(the tomes of the spell list but gzd cannot return arrays lol);
	}
	
	void LocalSetTomeIcon (int player, int i, String sprite_name) {
		if(player != consoleplayer || i < 0 || sprite.size() <= i) {
			return;
		}
		
		sprite [i] = Gc_Sprite.Load(sprite_name);
	}
	
	void LocalResetTomeIcon (int player, int i) {
		if(player != consoleplayer || i < 0 || sprite.size() <= i) {
			return;
		}
		
		sprite [i] = sprite_backup [i];
	}
	
	TextureId At (int i) const {
		if(0 <= i && i < sprite.size()) {
			return sprite [i];
		}
		
		return empty_sprite;
	}
	
	Gc_SpellCollection SpellPtr () const {
		return spell_list;
	}
}
